<template>
    <!--搜 索 框 的设计-->
    <div class="container">
        <!--搜 索 框 -->
        <div class="search">
            <div class="search-item weatherWidth">
                <input type="text" placeholder="请输入城市名 " v-model="city">
                <button class="iconfont icon-sousuo" @click="onSearch"><el-icon>
                        <Search />
                    </el-icon>
                </button>
            </div>
        </div>
        <div>

            <div class="weather-summary">
                {{ city2 }}天 气 <br>

                <img :src="`src/assets/images/${weather.icon}.svg`" alt="">
                <p> {{ weather.temp + "°C" }}</p>
                <span class="maintext">今天白天{{ weather.text }}，夜晚多云，比昨天冷很多，现在{{ weather.temp }}°，有{{ weather.windDir
                    }}，空气质量是{{ weather.windSpeed }}。
                </span>
                <el-row class="row-bg" justify="space-between">
                    <el-col :span="6">
                        体感温度:{{ weather.feelsLike }}°C

                    </el-col>
                    <el-col :span="6">
                        <div class="grid-content ep-bg-purple-light" />
                    </el-col>
                    <el-col :span="6">
                        <div class="grid-content ep-bg-purple" />
                    </el-col>
                </el-row>
                <el-row class="row-bg" justify="space-between">
                    <el-col :span="6">
                        相对湿度:{{ weather.humidity }}%
                    </el-col>
                    <el-col :span="6">
                        <div class="grid-content ep-bg-purple-light" />
                    </el-col>
                    <el-col :span="6">
                        <div class="grid-content ep-bg-purple" />
                    </el-col>
                </el-row>
            </div>

        </div>
    </div>



</template>
<script setup lang="ts">
import { Search } from "@element-plus/icons-vue";
import { onMounted, ref } from "vue"
import axios from "axios";
const city = ref("郑州")
const city2 = ref("郑州")
const weather = ref({} as any)
onMounted(() => {
    onSearch()
})
const onSearch = async () => {
    city2.value = city.value
    let res = await axios.get("https://devapi.qweather.com/v7/weather/now", {
        params: {
            location: '101010100',
            key: "94f66cc8c6c04c1f8d9b66db1079d662"
        }
    })
    console.log(res);
    weather.value=res.data.now
}




</script>
<style scoped >
.el-col{
    background: linear-gradient(#bfc3c6, #4f4a4a);
    color: rgb(250, 248, 248);
    font-size: 18px;
    text-align: center;
    border-radius: 5px;
    margin-top: 10px;
    height: 30px;

}
.container{
    color: rgb(80, 82, 84);
}
.weatherWidth{
    width: 50%;
    margin-top: 11px;
}
.search{
    background-color: rgb(210, 208, 208);
    padding: 10px 0;
}
.iconfont {
    font-weight: 700;
    color: rgb(252, 124, 44);
    margin-right: 15px;
    background: 0;
    border: 0;
    cursor: pointer;
    /*变小手*/
   
}


/* 搜索框的样式 */
.search-item {
     display: flex;
     border-radius: 100px;
     background-color: #fff;
    width: 100%;
    height: 30px;
    justify-content: space-between;
    align-items: center;

}

.search-item input {
    flex: 1 1 0;
    margin: 0 15px;
    line-height: 24px;
    border: 0;

}
.weather-summary{
    background-color: rgb(171, 171, 167);
    img{
        display: flex;
        justify-content: center;
        text-align: center;
        margin: 0 auto;
        width: 80px;
        height: 80px;
    }
    p{
        padding-top: 5px;
        text-align: center;
        font-size: 30px;
        font-weight: 700;
        color: rgb(255, 255, 255);
    }
    .maintext{
        text-align: center;
        font-size: 15px;
        color: rgb(9, 9, 9);
        font-weight: 700;
    }
}
</style>